package com.geek.bams.entity;

import com.geek.bams.exception.BalanceNotEnoughException;

import java.io.Serializable;

/**
 * @Desc TODO
 * @Author wangpeng
 * @Date 2025/10/13
 */
public class SavingAccount extends Account{


    public SavingAccount() {
    }

    public SavingAccount(Long id, String name, String password, String personId, String email, double balance) {
        super(id, name, password, personId, email, balance);
    }

    /**
     * 取款方法
     * @param money  取钱
     * @return  账户本身
     */
    public Account withdraw(double money) throws BalanceNotEnoughException {
        if(this.getBalance()>=money){
            this.setBalance(this.getBalance() - money);
            return this;
        }
        /*System.out.println("您的账户余额不足！");
        return this;*/
        throw new BalanceNotEnoughException("您的账户余额不足！");
    }

}
